package com.nova.bluetooth.helpUtils;

import android.view.View;

public abstract class OnClickEvent implements View.OnClickListener {

    public static long lastTime;

    public abstract void singleClick(View v);

    protected int duration = 300;

    public void setDuration(int duration) {
        this.duration = duration;
    }

    @Override
    public void onClick(View view) {
        if (onDoubClick()) {
            return;
        }
        singleClick(view);
    }

    public boolean onDoubClick() {
        boolean flag = false;
        long time = System.currentTimeMillis() - lastTime;

        if (time < duration) {
            flag = true;
        }
        lastTime = System.currentTimeMillis();
        return flag;
    }
}
